<!DOCTYPE html>
<html>
<head>
<style>
    div{
        border:1px solid red;
    }
    span{
        border:1px solid green;
    }
    a{
        border:1px solid blue;
    }
    .someClass{
        border:1px solid purple;
    }
</style>
<script src="crel.js"></script>
<script src="https://rawgithub.com/KoryNunn/bench/master/bench.js"></script>
<script>
    window.onload = function(){
        document.getElementsByTagName('body')[0].appendChild(crel('div', crel('div', {'class':'someClass'}, crel('a',{href:'http://www.google.com/'}, 'Link to google')), crel('span')));
        
        var bench = new Bench();
        
        // Test normal        
        bench.addTest(function(){
            var result = document.createElement('div');
            result.setAttribute('stuff','things');
            result.appendChild(document.createElement('a'));
        }, "document.CreateElement");
        
        // Test crel
        bench.addTest(function(){
            crel('div',{stuff:'things'},crel('a'));
        }, "crel");
        
        createElement = function(type){
            return document.createElement(type);
        }
        
        // Test createElement with 1 layer of proxy.
        bench.addTest(function(){
            var result = createElement('div');
            result.setAttribute('stuff','things');
            result.appendChild(createElement('a'));
        }, "proxy");
        
        // Test normal for empty nodes.
        bench.addTest(function(){
            document.createElement('div');
        }, "document.createElement empty node");
        
        // Test crel for empty nodes.
        bench.addTest(function(){
            crel('div');
        }, "crel empty node");
        
        bench.run();
        
        
        for(var i = 0; i < bench.tests.length; i++){
            var test = bench.tests[i]
            document.getElementsByTagName('body')[0].appendChild(crel('p',test.name + " runtime: " + test.result + "ms"));
        }
        
    };
</script>
</head>
<body>
</body>
</html>